<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script>
        //保存结果的提示
        function showResult() {
            showResultDiv(true);
            window.setTimeout("showResultDiv(false)", 3000);
            change_back();
        }
        function showResultDiv(flag) {
            var divResult = document.getElementById("save_result_info");
            if (flag)
                divResult.style.display = "block";
            else
                divResult.style.display = "none";
        }


        //切换资费类型
        var isFirst = true;
        var val_5 = 0;
        var val_6;
        var val_7;
        function feeTypeChange(type) {
            var inputArray = document.getElementById("update_one").getElementsByTagName("input");
            if (isFirst) {
                val_5 = inputArray[5].value;
                val_6 = inputArray[6].value;
                val_7 = inputArray[7].value;
                isFirst = false;
            }
            if (type === 1) {
                inputArray[5].readOnly = true;
                inputArray[5].value = "";
                inputArray[5].placeholder = "----默认不填----";
                inputArray[5].style = "font-style: italic;";
                inputArray[6].readOnly = false;
                inputArray[6].value = val_6;
                inputArray[6].placeholder = "";
                inputArray[6].style = "font-style: normal;";
                inputArray[7].readOnly = true;
                inputArray[7].value = "";
                inputArray[7].placeholder = "----默认不填----";
                inputArray[7].style = "font-style: italic;";
            }
            else if (type === 2) {
                inputArray[5].readOnly = false;
                inputArray[5].value = val_5;
                inputArray[5].placeholder = "";
                inputArray[5].style = "font-style: normal;";
                inputArray[6].readOnly = false;
                inputArray[6].value = val_6;
                inputArray[6].placeholder = "";
                inputArray[6].style = "font-style: normal;";
                inputArray[7].readOnly = false;
                inputArray[7].value = val_7;
                inputArray[7].placeholder = "";
                inputArray[7].style = "font-style: normal;";
            }
            else if (type === 3) {
                inputArray[5].readOnly = true;
                inputArray[5].value = "";
                inputArray[5].placeholder = "----默认不填----";
                inputArray[5].style = "font-style: italic;";
                inputArray[6].readOnly = true;
                inputArray[6].value = "";
                inputArray[6].placeholder = "----默认不填----";
                inputArray[6].style = "font-style: italic;";
                inputArray[7].readOnly = false;
                inputArray[7].value = val_7;
                inputArray[7].placeholder = "";
                inputArray[7].style = "font-style: normal;";
            }
        }

        function change_update_one(o) {
            document.getElementById("update_one").style.display = "block";
            document.getElementById("main").style.display = "none";
            var td = o.parentElement.parentElement.childNodes;
            for (var i = 0, pl = td.length; i < pl; i++) {
                console.log(td[i]);
            }
            document.getElementById("11").value = td[0].textContent;
            document.getElementById("12").value = td[1].textContent;
            document.getElementById("16").innerHTML = td[10].textContent;
            switch (td[9].textContent) {
                case "1":
                    document.getElementById("package1").checked = "checked";
                    document.getElementById("13").readOnly = false;
                    document.getElementById("13").value = parseInt(td[2].textContent);
                    document.getElementById("13").style = "font-style: normal;";
                    document.getElementById("14").readOnly = false;
                    document.getElementById("14").value = parseInt(td[3].textContent);
                    document.getElementById("14").style = "font-style: normal;";
                    document.getElementById("15").readOnly = false;
                    document.getElementById("15").value = parseInt(td[4].textContent);
                    document.getElementById("15").style = "font-style: normal;";
                    break;
                case "2":
                    document.getElementById("timeBased1").checked = "checked";
                    document.getElementById("13").readOnly = true;
                    document.getElementById("13").value = "";
                    document.getElementById("13").placeholder = "----默认不填----";
                    document.getElementById("13").style = "font-style: italic;";
                    document.getElementById("14").readOnly = true;
                    document.getElementById("14").value = "";
                    document.getElementById("14").placeholder = "----默认不填----";
                    document.getElementById("14").style = "font-style: italic;";
                    document.getElementById("15").readOnly = false;
                    document.getElementById("15").value = parseInt(td[4].textContent);
                    document.getElementById("15").style = "font-style: normal;";
                    break;
                case "3":
                    document.getElementById("monthly1").checked = "checked";
                    document.getElementById("13").readOnly = true;
                    document.getElementById("13").value = "";
                    document.getElementById("13").placeholder = "----默认不填----";
                    document.getElementById("13").style = "font-style: italic;";
                    document.getElementById("14").readOnly = false;
                    document.getElementById("14").value = parseInt(td[3].textContent);
                    document.getElementById("14").style = "font-style: normal;";
                    document.getElementById("15").readOnly = true;
                    document.getElementById("15").value = "";
                    document.getElementById("15").placeholder = "----默认不填----";
                    document.getElementById("15").style = "font-style: italic;";
                    break;
            }
        }
    </script>


    <div id="save_result_info" class="save_success">保存成功！</div>
    <form action="/fee_updateOne" method="get" class="main_form">
        <div class="text_info clearfix"><span>资费ID：</span></div>
        <div class="input_info">
            <input type="text" class="readonly" name="costId" readonly value="" id="11"/>
            <div class="validate_msg_short">未启用资费，可以修改除ID外的所有信息</div>
        </div>
        <div class="text_info clearfix"><span>资费名称：</span></div>
        <div class="input_info">
            <input type="text" class="width300" name="name" value="" id="12"/>
            <span class="required">*</span>
            <div class="validate_msg_short">50长度的字母、数字、汉字和下划线的组合</div>
        </div>
        <div class="text_info clearfix"><span>资费类型：</span></div>
        <div class="input_info fee_type">
            <input type="radio" name="costType" value="3" id="monthly1" onclick="feeTypeChange(1);" />
            <label for="monthly1">包月</label>
            <input type="radio" name="costType" value="1" id="package1" onclick="feeTypeChange(2);" />
            <label for="package1">套餐</label>
            <input type="radio" name="costType" value="2" id="timeBased1" onclick="feeTypeChange(3);" />
            <label for="timeBased1">计时</label>
        </div>
        <div class="text_info clearfix"><span>基本时长：</span></div>
        <div class="input_info">
            <input type="text" name="baseDuration" value="" class="width100" id="13"/>
            <span class="info">小时</span>
            <span class="required">*</span>
            <div class="validate_msg_long">1-600之间的整数</div>
        </div>
        <div class="text_info clearfix"><span>基本费用：</span></div>
        <div class="input_info">
            <input type="text" name="baseCost" value="" class="width100" id="14"/>
            <span class="info">元</span>
            <span class="required">*</span>
            <div class="validate_msg_long">0-99999.99之间的数值</div>
        </div>
        <div class="text_info clearfix"><span>单位费用：</span></div>
        <div class="input_info">
            <input type="text" name="unitCost" value="" class="width100" id="15"/>
            <span class="info">元/小时</span>
            <span class="required">*</span>
            <div class="validate_msg_long">0-99999.99之间的数值</div>
        </div>
        <div class="text_info clearfix"><span>资费说明：</span></div>
        <div class="input_info_high">
                    <textarea class="width300 height70" name="descr" id="16">
                    </textarea>
            <div class="validate_msg_short">100长度的字母、数字、汉字和下划线的组合</div>
        </div>
        <div class="button_info clearfix">
            <input type="submit" value="保存" class="btn_save"  />
            <input type="button" value="取消" class="btn_save" onclick="change_back()"/>
        </div>
    </form>
